package com.bawan.vims.common.security;

import sun.misc.BASE64Encoder;

import com.bawan.vims.common.Constants;

/**
 * 加密工具类
 * <p> Description	: EncryptionUtil.java </p>
 * <p> Copyright	: Copyright (c) 2015 by FITT</p>
 * <p> Author 		: ZCC </p>
 * <p> Create		: 2015年3月11日 上午9:58:52 </p> 
 * <p> version 		: 1.0 </p>
 */
public abstract class EncryptionUtil{

	public static String getVerifyData(String plainText){
		return getHmacSha1(plainText);
	}
	
	public static String getHmacSha1(String plainText){
		HmacSHA1Helper hmac = new HmacSHA1Helper(Constants.VERIFY_DATA_KEY);
		byte[] bytes;
		try {
			bytes = hmac.encript(plainText.getBytes("utf-8"));
			BASE64Encoder base64Encoder = new BASE64Encoder();
			String verifyData = base64Encoder.encode(bytes);
			return verifyData;
		} catch (Exception e) {}
		return "";
	}
	
	public static String decrypt(String encryText){
		return "";
	}
	
	public static void main(String[] args) throws Exception{
		/*
		HmacSHA1Helper hmac = new HmacSHA1Helper("suntek_verify");
		byte[] bytes;
		try {
			bytes = hmac.encript("999006123456SUNTEKHYTAPP20130730104541".getBytes("utf-8"));
			BASE64Encoder base64Encoder = new BASE64Encoder();
			String verifyData = base64Encoder.encode(bytes);
			System.out.println(verifyData);
		} catch (Exception e) {}
		*/
		HmacSHA1Helper hmac = new HmacSHA1Helper("suntek_verify");
		byte[] bytes;
		try {
			bytes = hmac.encript("TestTest".getBytes()/*"SUNTEK_MOBILEAPPmobileapppwdCommand_SUNTEK_LoginAuthen2013073010454120130730104541000003".getBytes("utf-8")*/);
			BASE64Encoder base64Encoder = new BASE64Encoder();
			String verifyData = base64Encoder.encode(bytes);
			System.out.println(verifyData);
		} catch (Exception e) {}
	}
}